Textbook examples of recursion
نویسنده
چکیده
We discuss properties of recursive schemas related to McCarthy's " 91 function " and to Takeuchi's triple recursion. Several theorems are proposed as interesting candidates for machine verification, and some intriguing open questions are raised. John McCarthy and Ikuo Takeuchi introduced interesting recurrence equations as they were exploring the properties of recursive programs. McCarthy's function [7] f (x) = if x > 100 then x − 10 else f f (x + 11) has become known as the " 91 function, " since it turns out that f (x) = 91 for all x ≤ 101. Takeuchi's function [13] is a triple recursion t(x, y, z) = if x ≤ y then y else t t(x − 1, y, z), t(y − 1, z, x), t(z − 1, x, y) , which has proved useful for benchmark testing of Lisp systems because the recursion terminates only after the definition has been expanded a large number of times (assuming that previously computed values are not remembered). Neither of these functions is of practical importance, because no reasonable programmer would ever want to carry out such recursive computations on a realistic problem. Yet both functions are quite instructive because they illustrate important problems and techniques that arise when we consider the task of verifying computer programs formally. Therefore they make excellent examples for textbooks that discuss recursion. The purpose of this paper is to obtain new information about f (x) and t(x, y, z) and about several closely related functions. Several of the theorems proved below should provide good test material for automated verification systems. A few open problems are stated, illustrating the fact that extremely simple recursions can lead to quite difficult questions. 1. The 91 function. It is appropriate to begin by studying the 91 function, because 1991 is the year of John McCarthy's 64th birthday (and because a computer scientist's most significant birthday is the 64th). McCarthy originally wrote down the definition of f (x), as shown above, because he wanted to study a simple recursion whose properties could not be deduced by ordinary mathematical induction. After studying the definition, he was pleasantly surprised to discover that it had the totally unexpected " 91 property. " The 91 function certainly belongs to the set of significant textbook examples, because it is mentioned on at least 14 pages of Zohar Manna's well known text, Mathematical Theory of Computation [6]. The …
منابع مشابه
Recursive Bijections for Catalan Objects
In this note we introduce several instructive examples of bijections found between several different combinatorially defined sequences of sets. Each sequence has cardinalities given by the Catalan numbers. Our results answer some questions posed by R. Stanley in the addendum to his textbook. We actually discuss two types of bijection, one defined recursively and the other defined in a more loca...
متن کاملRhetorical Move Analysis in Accounting Textbooks
Textbooks considered as one of the most important genres of academic writings would guarantee effective teaching and learning in EFL/ESL courses. Since textbooks are gaining more and more importance, the knowledge of their rhetorical organization that provides learners and teachers with efficient use of their content seems necessary. This article describes the rhetorical organization of the tex...
متن کاملComputability in an Introductory Course
The programming approach to computability presented in the textbook by Kfoury, Moll, and Arbib in 1982 has been embedded into a programming course following the textbook by Abelson and Sussman. This leads to a course concept teaching good programming practice and clear theoretical concepts simultaneously. Here, we explain some of the main points of this approach: the halting problem, primitive ...
متن کاملFast Algorithms for Toeplitz and Hankel Matrices
The paper gives a self-contained survey of fast algorithms for solving linear systems of equations with Toeplitz or Hankel coefficient matrices. It is written in the style of a textbook. Algorithms of Levinson-type and of Schur-type are discussed. Their connections with triangular factorizations, Padè recursions and Lanczos methods are demonstrated. In the case in which the matrices possess add...
متن کاملImproving OO Example Programs
When teaching object oriented programming, educators rely heavily on textbook examples. However, research shows that such examples are often of insufficient quality regarding their object-oriented characteristics. In this paper, we present a number of guidelines for designing or improving object oriented example programs for novices. Using actual textbook examples, we show how the guidelines ca...
متن کامل